package push;

import helper.ImageData;
import helper.ImageProcessor;

import java.awt.Point;
import java.awt.Rectangle;

import framework.filters.AbstractPushFilter;
import framework.pipes.PushPipe;

/**
 * Apply the get region operation on the given image
 * 
 * @author Wetzel & Rusch
 * 
 */
public class GetRegionFilter extends AbstractPushFilter<ImageData> {

	Rectangle m_rectanlge;

	public GetRegionFilter(PushPipe<ImageData> pushPipe) {
		super(pushPipe);
	}

	public void setRectangle(Rectangle rectangle) {
		m_rectanlge = rectangle;
	}

	@Override
	public void doIt() {
		ImageProcessor ip = ImageProcessor.getInstance();
		m_data.setRoiImage(ip.getROI(m_data.getOriginalImage(), m_rectanlge));
		m_data.setPoint(new Point(m_rectanlge.x, m_rectanlge.y));
		m_data.setRoiImageOriginal(m_data.getRoiImage());
	}

}
